<template>
  <div class="">
    <h1>文章列表</h1>
    <child2
      v-for="item in list"
      :key="item.id"
      :item="item"
      @removes="removes"
    />
  </div>
</template>

<script>
import child2 from "../components/child2";
export default {
  data() {
    return {
      list: [],
    };
  },
  mounted() {
    this.getlist();
  },
  methods: {
    getlist() {
      this.$axios
        .get("https://api.it120.cc/small4/cms/news/list")
        .then((res) => {
          console.log(res);
          this.list = res.data.data;
        })
        .catch((err) => {});
    },
    removes(id) {
      this.list.forEach((item, index) => {
        if (item.id == id) {
          this.list.splice(index, 1);
        }
      });
    },
  },
  components: {
    child2,
  },
};
</script>

<style lang="scss"></style>
